package com.sjzl.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="tb_post")
public class Post extends BaseEntity{
	private String name;
	private String content;
	private Board board;
	private User user;
	/**
	 * 最后回复的用户
	 */
	private User userLastReplied;
	/**
	 * 最后回复的时间
	 */
	private Date dateLastReplied;
	
	/**
	 * 回帖
	 */
	private List<Reply> replys;
	
	/**
	 * 回帖数
	 */
	private Integer replyCount;
	
	/**
	 * 阅读量
	 */
	private Integer selectCount;
	
	/**
	 * 举报量
	 */
	private Integer reportCount;
	
	/**
	 * 上传附件
	 */
	private List<UploadFile> uploadFiles;
	
	/**
	 * 近期来访者
	 */
	private List<PostVisitor> PostVisitors = new ArrayList<PostVisitor>();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(length=20000000)
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	public Board getBoard() {
		return board;
	}
	public void setBoard(Board board) {
		this.board = board;
	}
	
	@ManyToOne
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	@ManyToOne
	public User getUserLastReplied() {
		return userLastReplied;
	}
	public void setUserLastReplied(User userLastReplied) {
		this.userLastReplied = userLastReplied;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDateLastReplied() {
		return dateLastReplied;
	}
	public void setDateLastReplied(Date dateLastReplied) {
		this.dateLastReplied = dateLastReplied;
	}
	
	@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE)
	public List<Reply> getReplys() {
		return replys;
	}
	public void setReplys(List<Reply> replys) {
		this.replys = replys;
	}
	
	public Integer getReplyCount() {
		return replyCount;
	}
	public void setReplyCount(Integer replyCount) {
		this.replyCount = replyCount;
	}
	
	public Integer getSelectCount() {
		return selectCount;
	}
	public void setSelectCount(Integer selectCount) {
		this.selectCount = selectCount;
	}
	
	public Integer getReportCount() {
		return reportCount;
	}
	public void setReportCount(Integer reportCount) {
		this.reportCount = reportCount;
	}
	
	@OneToMany(mappedBy = "post", cascade = {CascadeType.ALL})
	public List<UploadFile> getUploadFiles() {
		return uploadFiles;
	}
	public void setUploadFiles(List<UploadFile> uploadFiles) {
		this.uploadFiles = uploadFiles;
	}
	
	@OneToMany(mappedBy = "post")
	public List<PostVisitor> getPostVisitors() {
		return PostVisitors;
	}
	public void setPostVisitors(List<PostVisitor> postVisitors) {
		PostVisitors = postVisitors;
	}
	
}
